package org.fone.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2 //开启swagger
public class SwaggerConfig {

    //配置swagger2核心配置
    @Bean
    public Docket createRestApis(){
        return new Docket(DocumentationType.SWAGGER_2) //指定api的类型是swagger2
                .apiInfo(apiInfo())                   //用于定义API文档汇总信息
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.fone.controller"))  //指定扫描的controller
                .paths(PathSelectors.any())            //全部放行，全部接口都进行展示
                .build();
    }

    public ApiInfo apiInfo () {
        return new ApiInfoBuilder()
                .title("信息管理工具，数据流模块")
                .contact(new Contact(
                        "groupA",                       //作者
                        "https://www.groupA.com",         //网址
                        "groupA@gmail.com"              //邮箱
                ))
                .description("数据流模块API专用接口")    //接口描述
                .version("1.0.0")                          //版本
                .termsOfServiceUrl("http://www.groupA.com")   //网站地址
                .build();
    }

}
